package com.riekoff.particlecubeworld.editor;

import cc.creativecomputing.CCApp;
import cc.creativecomputing.CCApplicationManager;
import cc.creativecomputing.CCApplicationSettings;
import cc.creativecomputing.graphics.CCDrawMode;
import cc.creativecomputing.graphics.shader.CCGLSLShader;
import cc.creativecomputing.io.CCIOUtil;

public class ABrickShaderDemo extends CCApp {
	
	private CCGLSLShader _myShader;

	@Override
	public void setup() {
		_myShader = new CCGLSLShader(
			CCIOUtil.classPath(this, "brick_vertex.glsl"),
			CCIOUtil.classPath(this, "brick_fragment.glsl")
		);
		_myShader.load();
	}

	@Override
	public void update(final float theDeltaTime) {
	}

	@Override
	public void draw() {
		g.clear();
		
		g.color(255);
		_myShader.start();
		g.beginShape(CCDrawMode.QUADS);
		g.textureCoords(0, 0, 0);
		g.vertex(-width/2, -height/2);
		g.textureCoords(0, 1, 0);
		g.vertex( width/2, -height/2);
		g.textureCoords(0, 1, 1);
		g.vertex( width/2,  height/2);
		g.textureCoords(0, 0, 1);
		g.vertex(-width/2,  height/2);
		g.endShape();
		_myShader.end();
	}

	public static void main(String[] args) {
		CCApplicationManager myManager = new CCApplicationManager(ABrickShaderDemo.class);
		myManager.settings().size(500, 500);
		myManager.start();
	}
}
